<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta content="text/css" http-equiv="Content-Style-Type">
<title>2048Game</title>
</head>
<body>
<h1 align="center" class="root">
<a name="3r48dcrse8a3la45truhbearvv">2048Game</a>
</h1>
<div align="center" class="globalOverview">
<img src="2048Game_files/images/2048Game.jpg"></div>
<p class="relationships">参见: <a href="#7sfk4fhov7khcuuf48aao3njmd">set data</a>
</p>
<h2 class="topic">
<a name="72t5o7llucnq25941en0etntrr">crated</a>
</h2>
<p class="relationships">参见: <a href="#3jvde4k6a8gpbgmg7e0qa28u00">ready</a>, <a href="#7662da554g5v5g7uel3it4slbq">attached</a>
</p>
<h3 class="topic">
<a name="282s98v1fpsicuclt4eltv3fb4">&nbsp;get window size</a>
</h3>
<h3 class="topic">
<a name="3kbcr2ktf9q3e5s7f5uh8f06gc">&nbsp;set props: {titleDimension, titlePosistion}</a>
</h3>
<h3 class="topic">
<a name="6eu4mpgnjo818q9f9qn71p0dhh">&nbsp;set config</a>
</h3>
<h2 class="topic">
<a name="7sfk4fhov7khcuuf48aao3njmd">set data</a>
</h2>
<p class="relationships">参见: <a href="#3r48dcrse8a3la45truhbearvv">2048Game</a>, <a href="#3jvde4k6a8gpbgmg7e0qa28u00">ready</a>
</p>
<h3 class="topic">
<a name="3gao2aj5qmstk3j3ie8i7mri26">&nbsp;set size nxn</a>
</h3>
<h3 class="topic">
<a name="1dr1birb43gsj4k2qc1islqntg">&nbsp;set dimension</a>
</h3>
<h3 class="topic">
<a name="17nph9lm4bq2jha66gao3osq12">&nbsp;set star with number</a>
</h3>
<h3 class="topic">
<a name="2t7icq0deq68pambc6f57n889k">&nbsp;set tile position</a>
</h3>
<h3 class="topic">
<a name="2n0cge0i7ohslmndj57bmfo7b5">&nbsp;get config</a>
</h3>
<h2 class="topic">
<a name="3jvde4k6a8gpbgmg7e0qa28u00">ready</a>
</h2>
<p class="relationships">参见: <a href="#7sfk4fhov7khcuuf48aao3njmd">set data</a>, <a href="#72t5o7llucnq25941en0etntrr">crated</a>
</p>
<h3 class="topic">
<a name="0htu87qpcob2bpncmrocnh336p">&nbsp;get data from local</a>
</h3>
<h3 class="topic">
<a name="76jlr6b8r7hu560rrqtb4k25ev">&nbsp; judge data? </a>
</h3>
<p class="relationships">参见: <a href="#53cmql8bf1r67rflbbor7943m6">has data?</a>
</p>
<h2 class="topic">
<a name="53cmql8bf1r67rflbbor7943m6">has data?</a>
</h2>
<p class="relationships">参见: <a href="#313cfl237sup8mp4ve5fm3hpg0">continue game (yes)</a>, <a href="#0ncpquno05255kqiln0ebp8rhv">init game (no)</a>, <a href="#76jlr6b8r7hu560rrqtb4k25ev"> judge data? </a>
</p>
<h2 class="topic">
<a name="313cfl237sup8mp4ve5fm3hpg0">continue game</a>
</h2>
<p class="relationships">参见: <a href="#53cmql8bf1r67rflbbor7943m6">has data? (yes)</a>
</p>
<h3 class="topic">
<a name="20th1qmfj8f0s06gd5jiu55q1v">&nbsp;init grid array</a>
</h3>
<h3 class="topic">
<a name="1s13245pml705pa9fvmnbjbhnm">&nbsp;set last game data 
tiles list = data</a>
</h3>
<h3 class="topic">
<a name="5ab3bc4tmo2kmu074hqmu914gp">&nbsp;restore gmae</a>
</h3>
<h2 class="topic">
<a name="0ncpquno05255kqiln0ebp8rhv">init game</a>
</h2>
<p class="relationships">参见: <a href="#53cmql8bf1r67rflbbor7943m6">has data? (no)</a>
</p>
<h3 class="topic">
<a name="3ivrjbvfegkg22psie586vash6">&nbsp;init grid array</a>
</h3>
<h3 class="topic">
<a name="133i65hhdv4d40sodseakasim6">&nbsp;&nbsp;init array</a>
</h3>
<h3 class="topic">
<a name="37d12bhqvrabpd1a96ks9e2ii0">&nbsp;&nbsp;for in size arr[x]=[ ]</a>
</h3>
<h3 class="topic">
<a name="7l8sqfudbbbfol96jc8bifnhap">&nbsp;&nbsp;grid = array</a>
</h3>
<h3 class="topic">
<a name="66vtgbl1vs3tc0d52vusnr2sar">&nbsp;init tiles list = []</a>
</h3>
<h3 class="topic">
<a name="23df9ccuhhlsegiqvg1omqcc29">&nbsp;for in size =&gt; addRandomTile</a>
</h3>
<h2 class="topic">
<a name="7662da554g5v5g7uel3it4slbq">attached</a>
</h2>
<p class="relationships">参见: <a href="#72t5o7llucnq25941en0etntrr">crated</a>
</p>
<h3 class="topic">
<a name="0lrbi5deg7g7s04sqh3ujhu0m6">&nbsp;bind event</a>
</h3>
<h3 class="topic">
<a name="69u3p6fbkn8c08j4cv6smrimil">&nbsp;&nbsp;on window resize</a>
</h3>
<h3 class="topic">
<a name="1sk9qvajn94l85a6ia9t7gpbc4">&nbsp;&nbsp;&nbsp;reset props: {titleDimension, titlePosistion}</a>
</h3>
<h3 class="topic">
<a name="5r0asujdqaq7fb90e96gs6efb6">&nbsp;&nbsp;on move</a>
</h3>
<p class="relationships">参见: <a href="#3vrr41f538abal5p0t8r48c02m">move(direction)</a>
</p>
<h2 class="topic">
<a name="3vrr41f538abal5p0t8r48c02m">move(direction)</a>
</h2>
<p class="relationships">参见: <a href="#5r0asujdqaq7fb90e96gs6efb6">on move</a>, <a href="#7tain4vhv471cpl22s2qfmolqs">get vector</a>
</p>
<h2 class="topic">
<a name="14pr1orplbohcrp2uojtfufuon">get traversals</a>
</h2>
<p class="relationships">参见: <a href="#7tain4vhv471cpl22s2qfmolqs">get vector</a>, <a href="#59s6k540e69mfct1rc1eqd3020">for in traversals</a>
</p>
<h3 class="topic">
<a name="59p9qdi1vmpc0gckirlrmdv1qh">&nbsp;init arr { x:[ ], y:[ ] }</a>
</h3>
<h3 class="topic">
<a name="5mbla834da1g6hr1rokbbn62kn">&nbsp;for in size
x.push(pos),
y.push(pos)</a>
</h3>
<h3 class="topic">
<a name="6lfjj4m4vecl9ueh9j8943tkus">&nbsp;is down/right</a>
</h3>
<h3 class="topic">
<a name="3rpdp3julvh1b43t6lcgr2ggjg">&nbsp;&nbsp;down: y.reverse
right   x.reverse</a>
</h3>
<h2 class="topic">
<a name="7tain4vhv471cpl22s2qfmolqs">get vector</a>
</h2>
<p class="relationships">参见: <a href="#3vrr41f538abal5p0t8r48c02m">move(direction)</a>, <a href="#14pr1orplbohcrp2uojtfufuon">get traversals</a>
</p>
<h3 class="topic">
<a name="1umsgf0h5d65cs6h8rnvvisgh8">&nbsp;up      0=&gt;{x:0,y:-1}
right   1=&gt;{x:1,y:0}
down 2=&gt;{x:0,y:1} 
left     3=&gt;{x:-1,y:0}</a>
</h3>
<h2 class="topic">
<a name="59s6k540e69mfct1rc1eqd3020">for in traversals</a>
</h2>
<p class="relationships">参见: <a href="#14pr1orplbohcrp2uojtfufuon">get traversals</a>
</p>
<h3 class="topic">
<a name="6h3habo4i45qfbve98alik71vk">&nbsp;traversal[x][y]</a>
</h3>
<p class="relationships">参见: <a href="#6v2lhh19rqucaqpe3bnv1ke8n4">grid[x][y]</a>
</p>
<h3 class="topic">
<a name="45dn97r57r8lgt6lab02hdgnh6">&nbsp;自由主题</a>
</h3>
<h2 class="topic">
<a name="6v2lhh19rqucaqpe3bnv1ke8n4">grid[x][y]</a>
</h2>
<p class="relationships">参见: <a href="#6h3habo4i45qfbve98alik71vk">traversal[x][y]</a>, <a href="#48vqt7n9ccel3d17i0a7u1b1ah">findTIle({x,y}) (yes)</a>
</p>
<h2 class="topic">
<a name="48vqt7n9ccel3d17i0a7u1b1ah">findTIle({x,y})</a>
</h2>
<p class="relationships">参见: <a href="#6v2lhh19rqucaqpe3bnv1ke8n4">grid[x][y] (yes)</a>, <a href="#0svjcd9cc99np3acokjf2ht8pr">findFarthestPosition
((x,y),direction)</a>
</p>
<h3 class="topic">
<a name="5vbkmf9bfus60ifpnu0ij6c75j">&nbsp;filter in tiles list</a>
</h3>
<h2 class="topic">
<a name="0svjcd9cc99np3acokjf2ht8pr">findFarthestPosition
((x,y),direction)</a>
</h2>
<p class="relationships">参见: <a href="#48vqt7n9ccel3d17i0a7u1b1ah">findTIle({x,y})</a>, <a href="#0g9rpavfp4has7i8e6vg946aop">findTile(next)</a>
</p>
<h3 class="topic">
<a name="090cg6n5dgu23embq1gu0rn1ku">&nbsp;do add offset 
while (next position) {
	 within boundary,
	 !grid[next.x][next.y]
}
return {
	current position,
	next position
}</a>
</h3>
<h2 class="topic">
<a name="0g9rpavfp4has7i8e6vg946aop">findTile(next)</a>
</h2>
<p class="relationships">参见: <a href="#0svjcd9cc99np3acokjf2ht8pr">findFarthestPosition
((x,y),direction)</a>, <a href="#70muo5mf31e9ollbvtv6hrjrio">has tile</a>
</p>
<h2 class="topic">
<a name="70muo5mf31e9ollbvtv6hrjrio">has tile</a>
</h2>
<p class="relationships">参见: <a href="#0g9rpavfp4has7i8e6vg946aop">findTile(next)</a>, <a href="#2pqg3ncpegcgi2cdj46geiicq4">next.value == current.value (yes)</a>
</p>
<h2 class="topic">
<a name="2pqg3ncpegcgi2cdj46geiicq4">next.value == current.value</a>
</h2>
<p class="relationships">参见: <a href="#70muo5mf31e9ollbvtv6hrjrio">has tile (yes)</a>, <a href="#076f504d2u4fogjhl5g0net3pf">moveTile (no)</a>, <a href="#4fdp110esibgng34ekjl7eff83">mergeTile (yes)</a>
</p>
<h2 class="topic">
<a name="076f504d2u4fogjhl5g0net3pf">moveTile</a>
</h2>
<p class="relationships">参见: <a href="#2pqg3ncpegcgi2cdj46geiicq4">next.value == current.value (no)</a>
</p>
<h3 class="topic">
<a name="36qv5f3mhtsv7pj4rilebiemis">&nbsp;grid[x][y] = 0</a>
</h3>
<h3 class="topic">
<a name="506m2p909u5fb6dchnffsanmm7">&nbsp;grid[next.x][next.y] = 1</a>
</h3>
<h3 class="topic">
<a name="4c41v2h8sgprbqplkmfhd4i0l9">&nbsp;reset tile(x,y)</a>
</h3>
<h2 class="topic">
<a name="4fdp110esibgng34ekjl7eff83">mergeTile</a>
</h2>
<p class="relationships">参见: <a href="#2pqg3ncpegcgi2cdj46geiicq4">next.value == current.value (yes)</a>
</p>
<h3 class="topic">
<a name="47t1rkmfsish4e05rsgpfeu20s">&nbsp;double next value</a>
</h3>
<h3 class="topic">
<a name="6vdas9cjbgd52sl6nl2sgvmpto">&nbsp;set merged = true</a>
</h3>
<h3 class="topic">
<a name="78g9u6bmbseam6rloh4hetkd15">&nbsp;remove tile from tiles list</a>
</h3>
<h3 class="topic">
<a name="7r473b2sejpq9ol8qdhq2vc2uf">&nbsp;grid[x][y] = 0</a>
</h3>
<h3 class="topic">
<a name="79m5av8onh3o7rc5ptpfm0t4fb">&nbsp;update score</a>
</h3>
<h2 class="topic">
<a name="17n59q3ggooor6488sn7euuuoi">moved</a>
</h2>
<p class="relationships">参见: <a href="#402v0jv81u49q7q1qsr866c4db">judge has available
tileMatchesAvailable (yes)</a>
</p>
<h2 class="topic">
<a name="402v0jv81u49q7q1qsr866c4db">judge has available
tileMatchesAvailable</a>
</h2>
<p class="relationships">参见: <a href="#17n59q3ggooor6488sn7euuuoi">moved (yes)</a>, <a href="#5ue9cp05au1jd982r4rhgiqb47">gameove (no)</a>
</p>
<h2 class="topic">
<a name="5ue9cp05au1jd982r4rhgiqb47">gameove</a>
</h2>
<p class="relationships">参见: <a href="#402v0jv81u49q7q1qsr866c4db">judge has available
tileMatchesAvailable (no)</a>
</p>
</body>
</html>
